namespace B.S.BasicData.EroorCode
{
    public class ApiResult<T>
    {
        public ApiResultCode Code { get; set; } // 状态码
        public string Message { get; set; } // 提示信息
        public T Data { get; set; } // 返回数据

        public ApiResult() { }

        public ApiResult(ApiResultCode code, string message, T data)
        {
            Code = code;
            Message = message;
            Data = data;
        }

        public static ApiResult<T> Success(T data, string message = "成功")
        {
            return new ApiResult<T>(ApiResultCode.Success, message, data);
        }

        public static ApiResult<T> Fail(string message = "失败", ApiResultCode code = ApiResultCode.Error)
        {
            return new ApiResult<T>(code, message, default(T));
        }
    }
} 